﻿/*
 * 由SharpDevelop创建。
 * 用户： XiaoSanYa
 * 日期: 2016/11/12
 * 时间: 21:49
 * 
 * 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
 */
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using AutoRunner.Device;

namespace AutoRunner.Test
{
	/// <summary>
	/// Description of MainForm.
	/// </summary>
	public partial class MainForm : Form
	{
		PLCDevice plc1;
		bool isrunning;
		
		public MainForm()
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			
			//
			// TODO: Add constructor code after the InitializeComponent() call.
			//
			plc1 = new PLCDevice();
			isrunning = false;
		}
		
		void ButtonStartClick(object sender, System.EventArgs e)
		{
			if(isrunning)
			{
				plc1.StopDevice();
				isrunning = false;
			}
			else
			{
				string ip = textBoxIp.Text;
				int port = int.Parse(textBoxPort.Text);
				plc1.SetAddress(ip, port);
				isrunning = plc1.StartDevice();
			}
		}
	}
}
